package com.ctrip.framework.apollo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ctrip.framework.apollo.biz.message.MessageSender;
import com.ctrip.framework.apollo.biz.message.Topics;
import com.ctrip.framework.apollo.biz.utils.ReleaseMessageKeyGenerator;

@RestController
public class ReleaseController {

	@Autowired
	private MessageSender messageSender;

	@GetMapping("/send")
    public boolean send() {
		// 模拟发送Release消息
		messageSender.sendMessage(ReleaseMessageKeyGenerator.generate("medusa", "default", "application"), Topics.APOLLO_RELEASE_TOPIC);
		return true;
	}

	// 客户端会发起一个Http请求到Config Service的notifications/v2接口，也就是NotificationControllerV2，见apollo-client《5长轮询更新机制》
	// http://127.0.0.1:8085/notifications/v2?cluster=default&appId=medusa&ip=10.30.160.154&notifications=%5B%7B%22namespaceName%22%3A%22application%22%2C%22notificationId%22%3A-1%7D%5D

	// 读取配置
	// http://127.0.0.1:8085/configs/medusa/default/application?ip=10.30.161.170

}
